#!/bin/bash
#!/bin/bash
path=$(pwd)
source ${path}/conf/base.sh
check_docker(){
  docker_images_old=`docker images --format {{.Repository}}:{{.Tag}}`
for i in ${docker_images_old}
do
  echo -e "\033[034m $i \033[0m"
done
}
echo -e "\033[034m========================= check Network ==============================\033[0m"
network
echo -e "\033[034m================== check Firewalld && selinux ========================\033[0m"
check
iptables -nL
echo -e "\033[034m====================== check docker_install ==========================\033[0m"
check_docker
echo -e "\033[034m====================== check docker_images ==========================\033[0m"
docker images
images=`docker images --format {{.Repository}}:{{.Tag}}|wc -l`
  if [ $images -eq 5 ];then
        echo -e "\033[032mImage upload succeeded\033[0m"
else
        echo -e "\033[031mImage upload failed \033[0m"
          env=`docker images --format {{.Repository}}:{{.Tag}}`
          for i in $env
          do
            nums=(29 100 13 8 91 44)
          #[ $i == grafana/grafana:latest ] && echo -e "\033[32mgrafana/grafana:latest upload succeeded \033[0m"  \
          #||echo -e "\033[31mgrafana/grafana:latest upload faild \033[0m"
          #[ $i == prom/prometheus:latest ] && echo -e "\033[32mprom/prometheus:latest upload succeeded \033[0m"  \
          # ||echo -e "\033[31mprom/prometheus:latest upload faild \033[0m"
          #[ $i == prom/node-exporter:latest ] && echo -e "\033[32mprom/node-exporter:latest upload succeeded \033[0m"  \
          #  ||echo -e "\033[31mprom/node-exporter:latest upload faild \033[0m"
          #[ $i == prom/mysqld-exporter:latest ] && echo -e "\033[32mprom/mysqld-exporter:latest:latest upload succeeded \033[0m"  \
          #   ||echo -e "\033[31mprom/mysqld-exporter:latest upload faild \033[0m"
          #[ $i == google/cadvisor:latest ] && echo -e "\033[32mgoogle/cadvisor:latest:latest upload succeeded \033[0m"  \
          #    ||echo -e "\033[31mgoogle/cadvisor:latest upload faild \033[0m"
          case $i in
          'grafana/grafana:latest')
          echo -e "\033[32mgrafana/grafana:latest upload succeeded \033[0m"  \
              ||echo -e "\033[31mgrafana/grafana:latest upload faild \033[0m";;
            'prom/prometheus:latest')
          echo -e "\033[32mprom/prometheus:latest upload succeeded \033[0m"  \
              ||echo -e "\033[31mprom/prometheus:latest upload faild \033[0m";;
          'prom/node-exporter:latest')
          echo -e "\033[32mprom/node-exporter:latest upload succeeded \033[0m"  \
              ||echo -e "\033[31mprom/node-exporter:latest upload faild \033[0m";;
          'prom/mysqld-exporter:latest')
           echo -e "\033[32mprom/mysqld-exporter:latest:latest upload succeeded \033[0m"  \
              ||echo -e "\033[31mprom/mysqld-exporter:latest upload faild \033[0m";;
          'google/cadvisor:latest')
          echo -e "\033[32mgoogle/cadvisor:latest:latest upload succeeded \033[0m"  \
              ||echo -e "\033[31mgoogle/cadvisor:latest upload faild \033[0m";;
         esac
          done
fi